<?php
class BoardmeetingsController extends AppController {

    public $helpers = array('Html', 'Form');
    public $components = array('Session');

    public function index() {
        $pageTitle ="Worldwide Seventh-day Adventist Church - Kwabrafoso: Church Board Meetings List";
        $in_record_data = $this->Boardmeeting->find('all');
        $this->set(compact('in_record_data','pageTitle'));
    }

    
    public function add(){
    $pageTitle ="Worldwide Seventh-day Adventist Church - Kwabrafoso: Add Church Board Meetings Details";
     if($_POST){
       // pr($_POST);
        $data['Boardmeeting'] = array(
            'bmid' => $_POST['bmid'],
            'bmdate' => $_POST['bmdate'],
            'bmtype' => $_POST['bmtype'],
            'totno' => $_POST['totno'],
            'quorum' => $_POST['quorum'],
            'mpresent' => $_POST['mpresent'],
            'mabsent' => $_POST['mabsent'],
            'venue' => $_POST['venue'],
            'stime' => $_POST['stime'],
            'etime' => $_POST['etime'],
            'agenda' => $_POST['agenda'],
            'chairp' => $_POST['chairp'],
            'recorder' => $_POST['recorder'],
            'actions' => $_POST['actions']
        );

        if(!$this->Boardmeeting->save($data)){
            $this->Session->setFlash('Error Saving Board Meetings');
        }else{
             $this->Session->setFlash('Board Meetings Saved');
            $this->redirect('index');
        }
    }

    $this->set(compact('pageTitle','errorMsg'));
}
    
    // A functin to delete Personal Details
    public function delete($id = null)
    {
       if (!$id) 
       {
        $this->Session->setFlash('Invalid id for Board Meetings');
        $this->redirect(array('action' => 'index'));
    }
    if ($this->Boardmeeting->delete($id)) 
    {
        $this->Session->setFlash('Board Meeting Deleted Please');
    } else 
    {
        $this->Session->setFlash(__('Board Meeting Not Deleted', true));
    }
    $this->redirect(array('action' => 'index'));
}

    // A functin to edit Personal Details
    function edit($id = null){
    $record_id = $id;
    $conditions = array('Boardmeeting.id' => $record_id);
    $record = $this->Boardmeeting->find('first', array('conditions' => $conditions, 'recursive' => 1));
   // pr($record);
            
     $pageTitle ="Worldwide Seventh-day Adventist Church - Kwabrafoso: Edit Church Board Meetings";
     if($_POST){
        //pr($_POST);
        $data['Boardmeeting'] = array(
            'bmid' => $_POST['bmid'],
            'bmdate' => $_POST['bmdate'],
            'bmtype' => $_POST['bmtype'],
            'totno' => $_POST['totno'],
            'quorum' => $_POST['quorum'],
            'mpresent' => $_POST['mpresent'],
            'mabsent' => $_POST['mabsent'],
            'venue' => $_POST['venue'],
            'stime' => $_POST['stime'],
            'etime' => $_POST['etime'],
            'agenda' => $_POST['agenda'],
            'chairp' => $_POST['chairp'],
            'recorder' => $_POST['recorder'],
            'actions' => $_POST['actions']
        );

        if(!$this->Boardmeeting->save($data)){
            $this->Session->setFlash('Error Saving Data');
        }else{
             $this->Session->setFlash('Data Saved');
            $this->redirect('index');
        }
    }

    $this->set(compact('pageTitle','record'));
}

     // A functin to view Pernal Detail Records
    public function view($id) {
    if (!$id) {
        throw new NotFoundException(__('Invalid Record'));
    }

    $boardmeeting = $this->Boardmeeting->findById($id);
    if (!$boardmeeting) {
        throw new NotFoundException(__('Invalid Record'));
    }
    $this->set('Boardmeeting', $boardmeeting);
}

function report($id = null){
    $record_id = $id;
    $conditions = array('Boardmeeting.id' => $record_id);
    $record = $this->Boardmeeting->find('first', array('conditions' => $conditions, 'recursive' => 1));
//    pr($record);

}

}
?>